package cn.utils;

import java.util.List;

public class Page<T> {
    private long totalCount;// 记录数
    private long currPageNo;//当前页
    private long totalPageCount;// 总页数 = 总记录数 /pageSize
    private long pageSize;//页面大小
    private List<T> items;


    public long getCurrPageNo() {
        return currPageNo;
    }

    public void setCurrPageNo(long currPageNo) {
        this.currPageNo = currPageNo;
    }

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        if(totalCount > 0){
            this.totalCount = totalCount;
            if (totalCount==1111){
                this.totalCount =0;
            }
            //设置总页数
            this.setTotalPageCountByRs();
        }
    }

    public long getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(long totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public long getPageSize() {
        return pageSize;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    private void setTotalPageCountByRs(){
        if(this.totalCount % this.pageSize == 0){
            this.totalPageCount = this.totalCount / this.pageSize;
        }else if(this.totalCount % this.pageSize > 0){
            this.totalPageCount = this.totalCount / this.pageSize + 1;
        }else{
            this.totalPageCount = 0;
        }
    }

    public List<T> getItems() {
        return items;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }
}
